<?php
/**
 *
 * @package 
 * @since 1.0
 * @todo 首页、列表页面、详细页
 */
 
class IndexAction extends AllAction{
	//首页
	function index(){
        //var_dump(md5("admin"));
        $cp_index=M("cp")->where("is_index=1")->order("id desc")->select();
        foreach($cp_index as $k=>$v){
            $cp_img=M("pic")->where("pid=".$v['id']."")->find();
            $cp_index[$k]['header_img']=$cp_img['header_img'];
        }
        $this->assign("cp_index",$cp_index);
        $banner_index=M("banner")->order("id desc")->select();
        $this->assign("banner_index",$banner_index);
        
        $this->display();
	}
	//视频搜索
    function search(){

        $words=$_POST['words'];
        $this->assign("words",$words);
        import("@.ORG.Page");
        $count	= M("cp")->where("title LIKE '%".$words."%' ")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pro_list=M("cp")->where("title LIKE '%".$words."%' ")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('pro_list',$pro_list);
        $this->assign('page', $show);
        $this->display();
    }
    //视频列表
    function pro_list(){

        $cp_sort_id=$_GET['cp_sort_id'];
        $cp_sort_detail=M("cp_sort")->where("id=".$cp_sort_id."")->find();
        $this->assign("cp_sort_detail",$cp_sort_detail);
        import("@.ORG.Page");
        $count	= M("cp")->where("sort=".$cp_sort_id."")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pro_list=M("cp")->where("sort=".$cp_sort_id."")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('pro_list',$pro_list);
        $this->assign('page', $show);
        $this->display();
    }
    //视频详情
    function pro_content(){
        $cp_id=intval($_GET['cp_id']);
        $uid=$_SESSION['uid'];
        $cp_info=M("cp")->where("id=".$cp_id."")->find();
        $cp_sort=M("cp_sort")->where("id=".$cp_info['sort']."")->find();
        $cp_info['sort_name']=$cp_sort['title'];
        $this->assign('cp_info',$cp_info);
        $cps=M("cp")->where("sort=".$cp_info['sort']." and id!=".$cp_id."")->order("id desc")->limit(10)->select();
        $this->assign('cps',$cps);
        $cp_zan=M("cp_zan")->where("cp_id=".$cp_id." and uid=".$uid."")->find();
        $this->assign('cp_zan',$cp_zan);
        $cp_shoucang=M("cp_sc")->where("cp_id=".$cp_id." and uid=".$uid."")->find();
        $this->assign('cp_shoucang',$cp_shoucang);
        $cp_pl=M("cp_pl")->where("cp_id=".$cp_id." ")->order("id desc")->select();
        foreach($cp_pl as $k=>$v){
        	$user=M("users")->where("id='".$v['uid']."'")->find();
        	if(empty($user['name'])){
        		$user['name']=$user['username'];
        	}
        	$cp_pl[$k]['user']=$user;
        }
        $this->assign('cp_pl',$cp_pl);
        $this->display();
    }
    //我评论的视频
    function my_pl(){
		$uid=$_SESSION['uid'];
        import("@.ORG.Page");
        $count	= M("cp_pl")->where("uid=".$uid."")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pro_list=M("cp_pl")->where("uid=".$uid."")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach($pro_list as $k=>$v){
        	$pro_list[$k]['cp']=M("cp")->where("id=".$v['cp_id']." ")->find();
        }
        $this->assign('pro_list',$pro_list);
        $this->assign('page', $show);
        $this->display();
    }
    //我收藏的视频
    function my_sc(){
		$uid=$_SESSION['uid'];
        import("@.ORG.Page");
        $count	= M("cp_sc")->where("uid=".$uid."")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pro_list=M("cp_sc")->where("uid=".$uid."")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach($pro_list as $k=>$v){
        	$pro_list[$k]['cp']=M("cp")->where("id=".$v['cp_id']." ")->find();
        }
        $this->assign('pro_list',$pro_list);
        $this->assign('page', $show);
        $this->display();
    }
    //我点赞的视频
    function my_zan(){
		$uid=$_SESSION['uid'];
        import("@.ORG.Page");
        $count	= M("cp_zan")->where("uid=".$uid."")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pro_list=M("cp_zan")->where("uid=".$uid."")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach($pro_list as $k=>$v){
        	$pro_list[$k]['cp']=M("cp")->where("id=".$v['cp_id']." ")->find();
        }
        $this->assign('pro_list',$pro_list);
        $this->assign('page', $show);
        $this->display();
    }
	//赞 操作
    function do_zan(){
    	
        $cp_id = intval($_POST['cp_id']);
        if($cp_id<=0){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;
        }
        $cp=M('cp')->where("id='".$cp_id."'")->find();
        if(empty($cp)){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;			
		}
				
        $uid=$_SESSION['uid'];
		$user=M('users')->where("id='".$uid."'")->find();
		if(empty($user)){
            $rs['err_code'] = 1;
            $rs['err_msg'] = '登录信息过期，请重新登录';
            echo json_encode($rs);
            exit;			
		}
		
		$old_zan=M("cp_zan")->where("cp_id='".$cp_id."' and uid='".$uid."'")->find();
		if(empty($old_zan)){
            $new['zan']=1;
            $new['uid']=$uid;
            $new['cp_id']=$cp_id;
            $new['ctime']=time();		
            M("cp_zan")->add($new);
            M('cp')->where("id='".$cp_id."'")->setInc("zan");
            $new_cp=M('cp')->where("id='".$cp_id."'")->find();
            $rs['err_code'] = 0;
            $rs['add'] = 1;
            $rs['num'] = $new_cp['zan'];
            $rs['err_msg'] = "";
            echo json_encode($rs);
            exit;
		}else{
			$old_zan=M("cp_zan")->where("cp_id='".$cp_id."' and uid='".$uid."'")->delete();
			M('cp')->where("id='".$cp_id."'")->setDec("zan");
            $new_cp=M('cp')->where("id='".$cp_id."'")->find();
            $rs['err_code'] = 0;
            $rs['add'] = 0;
            $rs['num'] = $new_cp['zan'];
            $rs['err_msg'] = "";
            echo json_encode($rs);
		}
		
		
    }
    //收藏 操作
    function do_shoucang(){
    	
        $cp_id = intval($_POST['cp_id']);
        if($cp_id<=0){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;
        }
        $cp=M('cp')->where("id='".$cp_id."'")->find();
        if(empty($cp)){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;			
		}
				
        $uid=$_SESSION['uid'];
		$user=M('users')->where("id='".$uid."'")->find();
		if(empty($user)){
            $rs['err_code'] = 1;
            $rs['err_msg'] = '登录信息过期，请重新登录';
            echo json_encode($rs);
            exit;			
		}
		
		$old_zan=M("cp_sc")->where("cp_id='".$cp_id."' and uid='".$uid."'")->find();
		if(empty($old_zan)){
            $new['shoucang']=1;
            $new['uid']=$uid;
            $new['cp_id']=$cp_id;
            $new['ctime']=time();		
            M("cp_sc")->add($new);
            M('cp')->where("id='".$cp_id."'")->setInc("shoucang");
            $new_cp=M('cp')->where("id='".$cp_id."'")->find();
            $rs['err_code'] = 0;
            $rs['add'] = 1;
            $rs['num'] = $new_cp['shoucang'];
            $rs['err_msg'] = "";
            echo json_encode($rs);
            exit;
		}else{
			$old_zan=M("cp_sc")->where("cp_id='".$cp_id."' and uid='".$uid."'")->delete();
			M('cp')->where("id='".$cp_id."'")->setDec("shoucang");
            $new_cp=M('cp')->where("id='".$cp_id."'")->find();
            $rs['err_code'] = 0;
            $rs['add'] = 0;
            $rs['num'] = $new_cp['shoucang'];
            $rs['err_msg'] = "";
            echo json_encode($rs);
		}
		
		
    }
    //评论 操作
    function do_pl(){
    	
        $cp_id = intval($_POST['cp_id']);
        $content = $_POST['content'];
        if($cp_id<=0){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;
        }
        $cp=M('cp')->where("id='".$cp_id."'")->find();
        if(empty($cp)){
            $rs['err_code'] = 2;
            $rs['err_msg'] = '请选择视频';
            echo json_encode($rs);
            exit;			
		}
				
        $uid=$_SESSION['uid'];
		$user=M('users')->where("id='".$uid."'")->find();
		if(empty($user)){
            $rs['err_code'] = 1;
            $rs['err_msg'] = '登录信息过期，请重新登录';
            echo json_encode($rs);
            exit;
		}
		if(empty($user['name'])){
			$user['name']=$user['username'];
		}
		
		$new['content']=$content;
        $new['uid']=$uid;
        $new['cp_id']=$cp_id;
        $new['ctime']=time();		
        M("cp_pl")->add($new);
        $new['ctime_date']=date("Y-m-d H:i:s",$new['ctime']);
        $rs['err_code'] = 0;
        $rs['user'] = $user;
        $rs['pl'] = $new;
        $rs['err_msg'] = "";
        echo json_encode($rs);
        exit;
		
    }
    //个人中心
    function per_center(){
        $uid=$_SESSION['uid'];
        if($uid<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请登录");
        }
        $per_center_user_info=M("users")->where("id='".$uid."'")->find();
        $this->assign('per_center_user_info',$per_center_user_info);
        $this->display();
    }
    //注册
    function doreg(){
        $username=$_POST['name'];
        $pwd=$_POST['pwd'];
        $pwd1=$_POST['pwd1'];
        if($username==""){
            $this->error("请输入用户名");
        }
        if($pwd==""){
            $this->error("请输入密码");
        }
        if($pwd1==""){
            $this->error("请输入确认密码");
        }
        if($pwd!=$pwd1){
            $this->error("密码不一致");
        }
        $user_old=M("users")->where("username='".$username."'")->find();
        if(!empty($user_old)){
            $this->error("此用户名已注册");
        }
        $new['username']=$username;
        $new['pwd']=md5($pwd);
        $new['user_group']=2;
        $user_add=M("users")->add($new);
        if($user_add){
            $_SESSION['uid']=$user_add;
            $_SESSION['username']=$new['username'];
            $_SESSION['user_group']=$new['user_group'];
            $this->assign('jumpUrl', U('Index/index'));
            $this->success("注册成功");
        }else{
            $this->error("注册失败");
        }
    }
    function dologin(){
        $username=$_POST['name'];
        $pwd=md5($_POST['pwd']);
        $user_group=$_POST['user_group'];
        if($username==""){
            $this->error("请输入用户名");
        }
        if($pwd==""){
            $this->error("请输入密码");
        }

        $user_old=M("users")->where("username='".$username."' and pwd='".$pwd."' and user_group='".$user_group."'")->find();
        if(empty($user_old)){
            $this->error("用户名或密码错误");
        }else{
            $_SESSION['uid']=$user_old['id'];
            $_SESSION['username']=$user_old['username'];
            $_SESSION['user_group']=$user_old['user_group'];
            if($user_group==1){
                $this->assign('jumpUrl', U('Index/per_center'));
                $this->success("管理员登录成功");
            }else{
                $this->assign('jumpUrl', U('Index/index'));
                $this->success("登录成功");
            }
        }
    }
    function logout(){
        unset ($_SESSION['uid']);
        unset ($_SESSION['username']);
        $this->assign('jumpUrl', U('Index/index'));
        $this->success("注销成功");
    }
    //个人中心验证
    function doalter(){
        if($_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请登录");
        }
        $name=$_POST['name'];
        $age=$_POST['age'];
        $sex=$_POST['sex'];
        $address=$_POST['address'];
        $email=$_POST['email'];
        $uid=$_SESSION['uid'];
        if($name==""){
            $this->error("请输入姓名");
        }
        if($age==""){
            $this->error("请输入年龄");
        }
        if($address==""){
            $this->error("请输入地址");
        }
        if($email==""){
            $this->error("请输入email");
        }
        $new['name']=$name;
        $new['age']=$age;
        $new['sex']=$sex;
        $new['address']=$address;
        $new['email']=$email;;
        $user_update=M("users")->where("id=".$uid."")->save($new);
        if($user_update){
            $this->success("保存成功");
        }else{
            $this->error("保存失败");
        }
    }

    //修改密码
    function new_pwd(){
        if($_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请登录");
        }
        $this->display();
    }
    function dopwd(){
        if($_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请登录");
        }
        $pwd=md5($_POST['pwd']);
        $pwd1=$_POST['pwd1'];
        $pwd2=$_POST['pwd2'];
        $uid=$_SESSION['uid'];
        if($pwd==""){
            $this->error("请输入原密码");
        }
        if($pwd1==""){
            $this->error("请输入新密码");
        }
        if($pwd2==""){
            $this->error("请确认新密码");
        }
        if($pwd1!=$pwd2){
            $this->error("密码不一致");
        }
        $pwd_old=M("users")->where("pwd='".$pwd."' and id='".$uid."'" )->find();
        if(empty($pwd_old)){
            $this->error("旧密码不正确");
        }else{
            $new['pwd']=md5($pwd1);
            M("users")->where("id='".$uid."'" )->save($new);
            $this->success("修改成功");
        }
    }
    /*********  用户管理 开始   ********/
    function users(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        import("@.ORG.Page");
        $count	= M("users")->where("user_group!=1")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $users=M("users")->where("user_group!=1")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('users',$users);
        $this->assign('page', $show);
        $this->display();
    }
    function user_del(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $users=M("users")->where("id='".$id."'")->delete();
        if($users){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }
    function user_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $user_edit=M("users")->where("id='".$id."'")->find();
        $this->assign('user_edit',$user_edit);
        $this->display();
    }
    function douser_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $user_edit['id']=$_POST['id'];
        $user_edit['name']=$_POST['name'];
        $user_edit['sex']=$_POST['sex'];
        $user_edit['age']=$_POST['age'];
        $user_edit['address']=$_POST['address'];
        $user_edit['email']=$_POST['email'];
        if($user_edit['id']<=0){
            $user_edit['username']=$_POST['username'];
            $user_old=M("users")->where("username='".$user_edit['username']."'")->find();
            if(!empty($user_old)){
                $this->error("此用户名已注册");
            }
            $user_new=M("users")->add($user_edit);
        }else{
            $user_new=M("users")->where("id='".$user_edit['id']."'")->save($user_edit);
        }

        if($user_new){
            $this->assign('jumpUrl', U('Index/users'));
            $this->success("保存成功");
        }else{
            $this->error("保存失败");
        }
    }
    /*********  用户管理 结束   ********/

    /*********  分类管理 开始   ********/
    function sort(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        import("@.ORG.Page");
        $count	= M("cp_sort")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $sort_cp_sort=M("cp_sort")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('sort_cp_sortsdfsadf',$sort_cp_sort);
        $this->assign('page', $show);
        $this->display();
    }
    function sort_del(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $users=M("cp_sort")->where("id='".$id."'")->delete();
        if($users){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }
    function sort_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $sort_edit=M("cp_sort")->where("id='".$id."'")->find();
        $this->assign('sort_edit',$sort_edit);
        $this->display();
    }
    function dosort_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $user_edit['id']=$_POST['id'];
        $user_edit['title']=$_POST['title'];
        $user_edit['xu']=$_POST['xu'];
        if($user_edit['id']<=0){
            $user_new=M("cp_sort")->add($user_edit);
        }else{
            $user_new=M("cp_sort")->where("id='".$user_edit['id']."'")->save($user_edit);
        }
        if($user_new){
            $this->assign('jumpUrl', U('Index/sort'));
            $this->success("保存成功");
        }else{
            $this->error("保存失败");
        }
    }
    /*********  分类管理 结束   ********/

    /*********  视频管理 开始   ********/
    function cp(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        import("@.ORG.Page");
        $count	= M("cp")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $sort_cp_sort=M("cp")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach($sort_cp_sort as $k=>$v){
            $sort_tran=M("cp_sort")->where("id=".$v['sort']."")->find();
            $sort_cp_sort[$k]['sort_name']=$sort_tran['title'];
        }
        $this->assign('cp_sortsdfsadf',$sort_cp_sort);
        $this->assign('page', $show);
        $this->display();
    }
    function cp_del(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $users=M("cp")->where("id='".$id."'")->delete();
        if($users){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }
    function cp_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $sortssssss=M("cp_sort")->order("xu asc,id desc")->select();
        $this->assign("sortssssss",$sortssssss);
        $sort_edit=M("cp")->where("id='".$id."'")->find();
        $this->assign('cp_edit',$sort_edit);
        $this->display();
    }
    function docp_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $user_edit['id']=$_POST['id'];
        $user_edit['title']=$_POST['title'];
        $user_edit['sort']=$_POST['sort'];
        $user_edit['url']=$_POST['url'];
        $user_edit['intro']=$_POST['intro'];
        $user_edit['ctime']=time();
        $user_edit['is_index']=$_POST['is_index'];
        //var_dump($user_edit);exit;
        if($user_edit['id']<=0){
            $user_new=M("cp")->add($user_edit);
        }else{
            $user_new=M("cp")->where("id='".$user_edit['id']."'")->save($user_edit);
        }
        if($user_new){
            $this->assign('jumpUrl', U('Index/cp'));
            $this->success("保存成功");
        }else{
            $this->error("保存失败");
        }
    }
    /*********  视频管理 结束   ********/
	/*********  banner管理 开始   ********/
    function banner(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        import("@.ORG.Page");
        $count	= M("banner")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $banner=M("banner")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('banner',$banner);
        $this->assign('page', $show);
        $this->display();
    }
    function banner_del(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $users=M("banner")->where("id='".$id."'")->delete();
        if($users){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }
    function banner_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $banner_edit=M("banner")->where("id='".$id."'")->find();
        $this->assign('banner_edit',$banner_edit);
        $this->display();
    }
    function dobanner_edit(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $user_edit['id']=$_POST['id'];
        $user_edit['title']=$_POST['title'];
        $user_edit['to_url']=$_POST['to_url'];
        $user_edit['url']=$_POST['url'];
        $user_edit['ctime']=time();
        if($user_edit['id']<=0){
            $user_new=M("banner")->add($user_edit);
        }else{
            $user_new=M("banner")->where("id='".$user_edit['id']."'")->save($user_edit);
        }
        if($user_new){
            $this->assign('jumpUrl', U('Index/banner'));
            $this->success("保存成功");
        }else{
            $this->error("保存失败");
        }
    }
    /*********  banner 管理 结束   ********/
	/*********  评论管理 开始   ********/
    function pl_list(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        import("@.ORG.Page");
        $count	= M("cp_pl")->count();
        $Page	= New Page($count,8);
        $show	= $Page->show();
        $pl_list=M("cp_pl")->order("id desc")->limit($Page->firstRow.','.$Page->listRows)->select();
        foreach($pl_list as $k=>$v){
        	$pl_list[$k]['cp']=M("cp")->where("id=".$v['cp_id']." ")->find();
        	$pl_list[$k]['user']=M("users")->where("id=".$v['uid']." ")->find();
        	if(empty($pl_list[$k]['user']['name'])){
        		$pl_list[$k]['user']['name']=$pl_list[$k]['user']['username'];
        	}
        }
        $this->assign('pl_list',$pl_list);
        $this->assign('page', $show);
        $this->display();
    }
    function pl_del(){
        if($_SESSION['user_group']!=1 ||  $_SESSION['uid']<=0){
            $this->assign('jumpUrl', U('Index/login'));
            $this->error("请管理员登录");
        }
        $id=$_GET['id'];
        $users=M("cp_pl")->where("id='".$id."'")->delete();
        if($users){
            $this->success("删除成功");
        }else{
            $this->error("删除失败");
        }
    }
    /*********  评论管理 结束   ********/

    
} 